﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace mojoPortal.Web.RS.SBM.Telerik
{
    public partial class Announcement : Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void SqlDataSource1_OnInit(object sender, EventArgs e)
        {
            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings[mojoPortal.Web.RS.SBM.AppCode.Lib.RSSBMCommonFunctions.GetRSCompanyConnectionString()].ToString();
        }

        protected void RadScheduler1_AnnouncementDataBound(object sender, SchedulerEventArgs e)
        {
            string colorAttribute = e.Appointment.Attributes["AppointmentColor"];
            if (!string.IsNullOrEmpty(colorAttribute))
            {
                int colorValue;
                if (int.TryParse(colorAttribute, out colorValue))
                {
                    Color appointmentColor = Color.FromArgb(colorValue);
                    e.Appointment.BackColor = appointmentColor;
                    e.Appointment.BorderColor = Color.Black;
                    e.Appointment.BorderStyle = BorderStyle.Solid;
                    e.Appointment.BorderWidth = Unit.Pixel(1);
                }
            }
            e.Appointment.ToolTip = e.Appointment.Subject + ": " + e.Appointment.Description;

        }


        protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
        {
            //RadScheduler scheduler = (RadScheduler)sender;
            
            if (e.Container.Mode == SchedulerFormMode.AdvancedInsert || e.Container.Mode == SchedulerFormMode.AdvancedEdit)
            {


                //TextBox subjectBox = (TextBox)e.Container.FindControl("TitleTextBox");
                //subjectBox.Text = e.Appointment.Subject;

                //RadDateInput startInput = (RadDateInput)e.Container.FindControl("StartInput");
                //startInput.DateFormat = scheduler.AdvancedForm.DateFormat + " " + scheduler.AdvancedForm.TimeFormat;
                //startInput.SelectedDate = RadScheduler1.DisplayToUtc(e.Appointment.Start);

                //RadDateInput endInput = (RadDateInput)e.Container.FindControl("EndInput");
                //endInput.DateFormat = scheduler.AdvancedForm.DateFormat + " " + scheduler.AdvancedForm.TimeFormat;
                //endInput.SelectedDate = RadScheduler1.DisplayToUtc(e.Appointment.End);

                //CheckBox repeatCheck = e.Container.FindControl("RepeatCheckBox") as CheckBox;
                //if (repeatCheck != null)
                //{
                //    repeatCheck.Checked = e.Appointment.RecurrenceState == RecurrenceState.Master;
                //}
            }
        }
    }
}